import com.begonzales.locker.datadictionary.AppField;
import com.begonzales.locker.datadictionary.AppTable;
import com.begonzales.locker.dto.DTOAnnotation;
import com.begonzales.locker.dto.HeaderItemDTO;
import com.begonzales.locker.dto.ItemDTO;
import com.begonzales.locker.dto.MapperDomainTestCase;
import com.begonzales.locker.mapper.CTable;
import com.begonzales.locker.mapper.CTableColumns;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
        /*
		CTable tbl1 = new CTable();
		tbl1.tableName = "asset";
		tbl1.tableClassPath = "com.path.example.asset";
        tbl1.tableClassMapperPath = "com.path.example.assetmapper";
		
        tbl1.cols.add(  new CTableColumns("ID","DECIMAL","ID","Long",true));
		tbl1.cols.add(  new CTableColumns("NAME","VARCHAR","name","String"));
		tbl1.cols.add(  new CTableColumns("DESC","VARCHAR","desc","String"));

        HeaderItemDTO hid = new HeaderItemDTO();
        hid.setHeaderName("HeaderDTO");
        ItemDTO itmDTO = hid.addItem("transactionID", "String", "private");
        DTOAnnotation ano0 = itmDTO.addAnnotation("XmlElement","required", "true");
        ItemDTO itmDTO2 = hid.addItem("customerNumber", "String", "private");
        ItemDTO itmDTO3 = hid.addItem("compNumber", "String", "private");
        itmDTO3.addAnnotation("XmlElement","required", "true");
        ItemDTO itmDTO4 = hid.addItem("transactionDateTime", "Calendar", "private");
        itmDTO4.addAnnotation("XmlElement","required","true");
        itmDTO4.addAnnotation("XmlSchemaType","name","\"datetime\"");
        ItemDTO itmDTO5 = hid.add(new ItemDTO("transactionType","String","private"));
        DTOAnnotation ano1 = hid.getHeader().addAnnotation("XmlAccessorType","","XmlAccessType.FIELD");
        ano1.setNary(1);
        DTOAnnotation ano2 = hid.getHeader().addAnnotation("XmlType","name","\"header\"");
        String txt = hid.toString();
        hid.toFile("C:\\packages\\projects\\tmp\\HeaderDTO.java");
        //String txt = hid.getItemDeclarationString() + "\r\n" + hid.getSetPropertyString() + hid.getGetPropertyString();
        System.out.println(txt);

		String rm1 = tbl1.getResultMap();
		//System.out.println(rm1);

        String s1 = tbl1.emitMapper();
        //System.out.println(s1);

        //tbl1.writeToFileMapper("C:\\packages\\projects\\tmp\\assetMapper.xml");
        //tbl1.writeToFileEntity("C:\\packages\\projects\\tmp\\asset.java","asset");
        //tbl1.writeToFileInterface("C:\\packages\\projects\\tmp\\assetMapper.java","asset");
        */
        /**
         *    ASSET TABLE
         *
         */
        if ( false )
        {
        CTable tblAsset = new CTable();
		tblAsset.tableName = "AST";
		tblAsset.tableClassPath = "com.path.example.asset";
        tblAsset.tableClassMapperPath = "com.path.example.assetMapper";
        tblAsset.cols.add( new CTableColumns("PRNT_AST_ID","DECIMAL"," assetId","Long",true));
        tblAsset.cols.add( new CTableColumns("AST_NM","VARCHAR","assetName","String"));
        tblAsset.cols.add( new CTableColumns("AST_ALIAS_NM","VARCHAR","assetAliasName","String"));
        tblAsset.cols.add( new CTableColumns("AST_TYPE_ID","DECIMAL","assetTypeId","int"));
        tblAsset.cols.add( new CTableColumns("AST_SUB_TYPE_ID","DECIMAL","assetSubTypeId","int"));
        tblAsset.cols.add( new CTableColumns("GEO_ID","DECIMAL","geoId","int"));

        HeaderItemDTO hid = new HeaderItemDTO();
        hid.setHeaderName("AssetDTO");
        ItemDTO itmDTO1 = hid.addItem(new ItemDTO("assetId", "Long", "private"));
        itmDTO1.setPrimaryKey(true);
        DTOAnnotation ano0 = itmDTO1.addAnnotation("XmlElement","required", "true");
        ItemDTO itmDTO2 = hid.addItem(new ItemDTO("assetName", "String", "private"));
        ItemDTO itmDTO3 = hid.addItem(new ItemDTO("assetAliasName", "String", "private"));
        ItemDTO itmDTO4 = hid.addItem(new ItemDTO("assetTypeId", "String", "private"));
        ItemDTO itmDTO5 = hid.addItem(new ItemDTO("assetSubTypeId", "String", "private"));
        ItemDTO itmDTO6 = hid.addItem(new ItemDTO("geoId", "String", "private"));

        MapperDomainTestCase mtc = new MapperDomainTestCase();
        mtc.setItems(hid.getItem());
        mtc.setDomainName("Asset");
        mtc.setName("Asset");
        mtc.setTable(tblAsset);
        System.out.println(mtc.toString());
        mtc.toFile("C:\\packages\\projects\\tmp\\AssetMapperTestCase.java");
        System.out.println("=================================================");

        System.out.println(tblAsset.emitMapper());
        System.out.println("=================================================");
        System.out.println(tblAsset.getFileEntityJava("asset"));
        tblAsset.writeToFileMapper("C:\\packages\\projects\\tmp\\AssetMapper.xml");
        tblAsset.writeToFileEntity("C:\\packages\\projects\\tmp\\Asset.java","asset");
        tblAsset.writeToFileInterface("C:\\packages\\projects\\tmp\\AssetMapper.java", "asset");
        hid.toFile("C:\\packages\\projects\\tmp\\AssetDTO.java");
        }
        /**
        *
        *
        */
        if ( false )
        {
            AppTable at = new AppTable();
            at.setName("Asset");
            at.setTableName("AST");
            at.setTableClassMapperPath("com.nike.brand.thelocker.mapper.transaction."+at.getName()+"Mapper");
            at.setTableClassPath("com.nike.brand.thelocker.domain.transaction." + at.getName());
            at.add(new AppField("private","PRNT_AST_ID","DECIMAL","id","Long",true));
            at.add(new AppField("private","AST_NM","VARCHAR","assetName","String",false));
            at.add(new AppField("private","AST_ALIAS_NM","VARCHAR","assetAliasName","String",false));
            at.add(new AppField("private","AST_TYPE_ID","DECIMAL","assetTypeId","int",false));
            at.add(new AppField("private","AST_SUB_TYPE_ID","DECIMAL","assetSubTypeId","int",false));
            at.add(new AppField("private","GEO_ID","DECIMAL","geoId","int",false));
            at.add(new AppField("private","INACTV_RSN_ID","DECIMAL","inactiveReason","int",false));
            at.add(new AppField("private","STAT_CD","VARCHAR","statCode","String",false));

            System.out.println("========= TEST CASE ========= \n" + at.getMapperTestCase());
            System.out.println("========= MAPPER XML ========= \n" + at.getMapperXML());
            System.out.println("========= DOMAIN ENTITY ========= \n" + at.getDomainEntity());
            System.out.println("========= DOMAIN INTERFACE ========= \n" + at.getDomainInterface());
            System.out.println("========= DTO ========= \n" + at.getDtoFile());

            at.writeToFile("C:\\packages\\projects\\tmp\\AssetMapperTestCase.java",at.getMapperTestCase());
            at.writeToFile("C:\\packages\\projects\\tmp\\AssetMapper.xml",at.getMapperXML());
            at.writeToFile("C:\\packages\\projects\\tmp\\Asset.java",at.getDomainEntity());
            at.writeToFile("C:\\packages\\projects\\tmp\\AssetMapper.java",at.getDomainInterface());
            at.writeToFile("C:\\packages\\projects\\tmp\\AssetDTO.java",at.getDtoFile());
        }
        /**
        *
        *
        */
        if ( false )
        {
            AppTable astRep = new AppTable();
            astRep.setName("AssetRep");
            astRep.setTableName("AST_REP");
            astRep.setTableClassMapperPath("com.nike.brand.thelocker.mapper.transaction."+astRep.getName()+"Mapper");
            astRep.setTableClassPath("com.nike.brand.thelocker.domain.transaction." + astRep.getName());
            astRep.add(new AppField("private","AST_REP_ID","DECIMAL","id","Long",true));
            astRep.add(new AppField("private","AST_ID","DECIMAL","assetID","int",false));
            astRep.add(new AppField("private","PRSN_ID","DECIMAL","personID","int",false));

            System.out.println("========= TEST CASE ========= \n" + astRep.getMapperTestCase());
            System.out.println("========= MAPPER XML ========= \n" + astRep.getMapperXML());
            System.out.println("========= DOMAIN ENTITY ========= \n" + astRep.getDomainEntity());
            System.out.println("========= DOMAIN INTERFACE ========= \n" + astRep.getDomainInterface());
            System.out.println("========= DTO ========= \n" + astRep.getDtoFile());

            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"MapperTestCase.java",astRep.getMapperTestCase());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.xml",astRep.getMapperXML());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+".java",astRep.getDomainEntity());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.java",astRep.getDomainInterface());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"DTO.java",astRep.getDtoFile());
        }
        /**
        *
        *
        */
        if ( false )
        {
            AppTable astRep = new AppTable();
            astRep.setName("EmailAddressInfo");
            astRep.setTableName("EMAIL_ADDR");
            astRep.setTableClassMapperPath("com.nike.brand.thelocker.mapper.transaction."+astRep.getName()+"Mapper");
            astRep.setTableClassPath("com.nike.brand.thelocker.domain.transaction." + astRep.getName());
            astRep.add(new AppField("private","EMAIL_ADDR_ID","DECIMAL","id","Long",true));
            astRep.add(new AppField("private","EMAIL_LBL_NM","DECIMAL","labelName","String",false));
            astRep.add(new AppField("private","EMAIL_ADDR","DECIMAL","emailAddress","String",false));

            System.out.println("========= TEST CASE ========= \n" + astRep.getMapperTestCase());
            System.out.println("========= MAPPER XML ========= \n" + astRep.getMapperXML());
            System.out.println("========= DOMAIN ENTITY ========= \n" + astRep.getDomainEntity());
            System.out.println("========= DOMAIN INTERFACE ========= \n" + astRep.getDomainInterface());
            System.out.println("========= DTO ========= \n" + astRep.getDtoFile());

            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"MapperTestCase.java",astRep.getMapperTestCase());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.xml",astRep.getMapperXML());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+".java",astRep.getDomainEntity());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.java",astRep.getDomainInterface());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"DTO.java",astRep.getDtoFile());
        }

        if ( true )
        {
            AppTable astRep = new AppTable();
            astRep.setName("AssetAddressInfo");
            astRep.setTableName("AST_ADDR");
            astRep.setTableClassMapperPath("com.nike.brand.thelocker.mapper.transaction."+astRep.getName()+"Mapper");
            astRep.setTableClassPath("com.nike.brand.thelocker.domain.transaction." + astRep.getName());
            astRep.add(new AppField("private","AST_ADDR_ID","DECIMAL","id","Long",true));
            astRep.add(new AppField("private","ADDR_LBL_NM","VARCHAR","addressLabel","String",false));
            astRep.add(new AppField("private","ADDR_LIN_1","VARCHAR","address1","String",false));
            astRep.add(new AppField("private","ADDR_LIN_2","VARCHAR","address2","String",false));
            astRep.add(new AppField("private","ADDR_LIN_3","VARCHAR","address3","String",false));
            astRep.add(new AppField("private","ADDR_LIN_4","VARCHAR","address4","String",false));
            astRep.add(new AppField("private","CITY_NM","VARCHAR","cityFirst","String",false));
            astRep.add(new AppField("private","CITY_SECND_NM","VARCHAR","citySecond","String",false));
            astRep.add(new AppField("private","PO_BOX_NBR","VARCHAR","poBoxNumber","String",false));
            astRep.add(new AppField("private","PO_BOX_PSTL_CD","VARCHAR","poBoxPostalCode","String",false));
            astRep.add(new AppField("private","ST_PROV_NM","VARCHAR","stateProvinceName","String",false));
            astRep.add(new AppField("private","ADDR_REG_CD","VARCHAR","regCode","String",false));
            astRep.add(new AppField("private","ADDR_PSTL_CD","VARCHAR","postalCode","String",false));
            astRep.add(new AppField("private","ISO_CTRY_CD","VARCHAR","countryCode","String",false));
            astRep.add(new AppField("private","ISO_CTRY_NM","VARCHAR","countryName","String",false));

            System.out.println("========= TEST CASE ========= \n" + astRep.getMapperTestCase());
            System.out.println("========= MAPPER XML ========= \n" + astRep.getMapperXML());
            System.out.println("========= DOMAIN ENTITY ========= \n" + astRep.getDomainEntity());
            System.out.println("========= DOMAIN INTERFACE ========= \n" + astRep.getDomainInterface());
            System.out.println("========= DTO ========= \n" + astRep.getDtoFile());

            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"MapperTestCase.java",astRep.getMapperTestCase());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.xml",astRep.getMapperXML());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+".java",astRep.getDomainEntity());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.java",astRep.getDomainInterface());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"DTO.java",astRep.getDtoFile());
        }
        if ( false )
        {
            AppTable astRep = new AppTable();
            astRep.setName("AssetProfileInfo");
            astRep.setTableName("AST_PROFL_INFO");
            astRep.setTableClassMapperPath("com.nike.brand.thelocker.mapper.transaction."+astRep.getName()+"Mapper");
            astRep.setTableClassPath("com.nike.brand.thelocker.domain.transaction." + astRep.getName());
            astRep.add(new AppField("private","AST_ID","DECIMAL","id","Long",true));
            astRep.add(new AppField("private","FRST_NM","VARCHAR","firstName","String",false));
            astRep.add(new AppField("private","LAST_NM","VARCHAR","lastName","String",false));
            astRep.add(new AppField("private","MIDL_NM","VARCHAR","middleName","String",false));
            astRep.add(new AppField("private","PRSN_ID","DECIMAL","personId","long",false));
            astRep.add(new AppField("private","GNDR_ID","DECIMAL","genderId","String",false));
            astRep.add(new AppField("private","GNDR_CD","VARCHAR","genderCode","String",false));
            astRep.add(new AppField("private","GNDR_DESC","VARCHAR","genderDesc","String",false));
            astRep.add(new AppField("private","AST_TYPE_ID","DECIMAL","assetTypeId","long",false));
            astRep.add(new AppField("private","AST_TYPE_CD","VARCHAR","assetTypeCode","String",false));
            astRep.add(new AppField("private","AST_TYPE_DESC","VARCHAR","assetTypeDesc","String",false));
            astRep.add(new AppField("private","AST_SUB_TYPE_ID","DECIMAL","assetSubTypeId","long",false));
            astRep.add(new AppField("private","AST_SUB_TYPE_CD","VARCHAR","assetSubTypeCode","String",false));
            astRep.add(new AppField("private","AST_SUB_TYPE_DESC","VARCHAR","assetSubTypeDesc","String",false));

            System.out.println("========= TEST CASE ========= \n" + astRep.getMapperTestCase());
            System.out.println("========= MAPPER XML ========= \n" + astRep.getMapperXML());
            System.out.println("========= DOMAIN ENTITY ========= \n" + astRep.getDomainEntity());
            System.out.println("========= DOMAIN INTERFACE ========= \n" + astRep.getDomainInterface());
            System.out.println("========= DTO ========= \n" + astRep.getDtoFile());

            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"MapperTestCase.java",astRep.getMapperTestCase());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.xml",astRep.getMapperXML());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+".java",astRep.getDomainEntity());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.java",astRep.getDomainInterface());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"DTO.java",astRep.getDtoFile());
        }

        if ( false )
        {
            AppTable astRep = new AppTable();
            astRep.setName("AssetProfileInfo");
            astRep.setTableName("AST_PROFL_INFO");
            astRep.setTableClassMapperPath("com.nike.brand.thelocker.mapper.transaction."+astRep.getName()+"Mapper");
            astRep.setTableClassPath("com.nike.brand.thelocker.domain.transaction." + astRep.getName());
            astRep.add(new AppField("private","AST_ID","DECIMAL","id","Long",true));
            astRep.add(new AppField("private","FRST_NM","VARCHAR","firstName","String",false));
            astRep.add(new AppField("private","LAST_NM","VARCHAR","lastName","String",false));
            astRep.add(new AppField("private","MIDL_NM","VARCHAR","middleName","String",false));
            astRep.add(new AppField("private","PRSN_ID","DECIMAL","personId","long",false));
            astRep.add(new AppField("private","GNDR_ID","DECIMAL","genderId","String",false));
            astRep.add(new AppField("private","GNDR_CD","VARCHAR","genderCode","String",false));
            astRep.add(new AppField("private","GNDR_DESC","VARCHAR","genderDesc","String",false));
            astRep.add(new AppField("private","AST_TYPE_ID","DECIMAL","assetTypeId","long",false));
            astRep.add(new AppField("private","AST_TYPE_CD","VARCHAR","assetTypeCode","String",false));
            astRep.add(new AppField("private","AST_TYPE_DESC","VARCHAR","assetTypeDesc","String",false));
            astRep.add(new AppField("private","AST_SUB_TYPE_ID","DECIMAL","assetSubTypeId","long",false));
            astRep.add(new AppField("private","AST_SUB_TYPE_CD","VARCHAR","assetSubTypeCode","String",false));
            astRep.add(new AppField("private","AST_SUB_TYPE_DESC","VARCHAR","assetSubTypeDesc","String",false));

            System.out.println("========= TEST CASE ========= \n" + astRep.getMapperTestCase());
            System.out.println("========= MAPPER XML ========= \n" + astRep.getMapperXML());
            System.out.println("========= DOMAIN ENTITY ========= \n" + astRep.getDomainEntity());
            System.out.println("========= DOMAIN INTERFACE ========= \n" + astRep.getDomainInterface());
            System.out.println("========= DTO ========= \n" + astRep.getDtoFile());

            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"MapperTestCase.java",astRep.getMapperTestCase());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.xml",astRep.getMapperXML());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+".java",astRep.getDomainEntity());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"Mapper.java",astRep.getDomainInterface());
            astRep.writeToFile("C:\\packages\\projects\\tmp\\"+astRep.getName()+"DTO.java",astRep.getDtoFile());
        }

    }

}
